function autocompleta(f,id){
	var campo = document.getElementById(id);
	campo.value = f.innerHTML;
}
var ajaxCall=false;
function getXMLHTTP(){
	var xhr; 
	try {
		
		xhr = new XMLHttpRequest();
		//alert("Nativo");
	}catch (e){
		try {
			xhr = new ActiveXObject('Msxml2.XMLHTTP');   
			//alert("Msxml2");
		}catch (e2){
			try {
				xhr = new ActiveXObject('Microsoft.XMLHTTP');
				//alert("Microsoft");
			}catch (e3) {  
				xhr = false;
			}
		}
	}
	return xhr;
}
function verificarEda(){
	var div = document.getElementById("edaStatus");
	var xmlHttp = getXMLHTTP();
	xmlHttp.onreadystatechange = function(){ 
		 if(xmlHttp.readyState == 4){
			  if(xmlHttp.status == 200){
				div.innerHTML = xmlHttp.responseText; 
				//alert(xmlHttp.responseText);
			  }else {
				alert("Erro cod:" + xmlHttp.status);
			  }
			  setTimeout("verificarEda()",1000);
		 }
		 //alert("xmlHttp.readyState "+xmlHttp.readyState );
	}; 
	xmlHttp.open('GET', "verMensagemStatusEda.action?t="+(new Date().getTime()),  true); 
	xmlHttp.send(null);	
}
function autocomplete(f){
	if (ajaxCall) return;
	ajaxCall = true;
	var div = document.getElementById("auto_"+f.id);
	var textoProcurado = f.value;
	
	var xhr = getXMLHTTP();
  
	xhr.onreadystatechange = function(){ 
		 if(xhr.readyState == 4){
			  if(xhr.status == 200) 
				div.innerHTML = xhr.responseText; 
			  else 
				alert("Erro cod:" + xhr.status);
			  setTimeout("ajaxCall = false;",250);
		 }
	}; 

	xhr.open('GET', "autoCompletar.action?texto="+escape(textoProcurado)+"&campo="+f.id,  true); 
	xhr.send(null);
	//div.innerHTML = textoProcurado;
}
function fecharAutoComplete(v){
	var d = document.getElementById(v);
	d.innerHTML="";
}